﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Drawing;


namespace BattleThis
{
	public static class CommonHelper
	{
		/// <summary>
		/// Convert the Color to a hexadecimal format e.g #000000
		/// </summary>
		/// <param name="color">The color to fromat.</param>
		/// <returns>Hexadecimal Format of the color as string.</returns>
		public static string ToHex(this Color color)
		{
			return String.Format( "#{0:x2}{1:x2}{2:x2}", color.R, color.G, color.B );
		}

		/// <summary>
		/// Gets the local app data path.
		/// </summary>
		/// <param name="app">The app.</param>
		/// <returns>Local path to the appdata folder.</returns>
		public static string GetLocalAppDataPath(this HttpApplication app)
		{
			return app.Server.MapPath( "~/App_Data" );
		}

		/// <summary>
		/// Gets the local path of a specified virtualPath.
		/// </summary>
		/// <param name="app">The Web-Application.</param>
		/// <param name="virtualPath">The virtual path.</param>
		/// <returns>The local-system-path e.g. c:\..\..\sample.test</returns>
		public static string GetLocalPath( this HttpApplication app, string virtualPath )
		{
			return app.Server.MapPath( virtualPath  );
		}

	}
}